package com.gwcloud.leetcode.tags.array;

/** 
* @ClassName   : Leetcode1160 
* @author      : ganwei 
* @date        : 2020年6月15日 
* @Description : TODO 
*/
public class Leetcode1160 {
    /**
     * -解题思路，哈希表
     */
	public int countCharacters(String[] words, String chars) {
		int[] chararr = new int[26];
		for(int i = 0; i < chars.length(); i++) {
			char c = chars.charAt(i);
			chararr[c-'a']++;
		}
		
		int count = 0;
		for(String word : words) {
			int[] wchararr = new int[26];
			int cc = 1;
			for(int i = 0; i < word.length(); i++) {
				char c = word.charAt(i);
				wchararr[c-'a']++;
			}
			
			for(int i = 0; i < 26; i++) {
				if(chararr[i] < wchararr[i]) {
					cc = 0;
				}
			}
			count += (cc * word.length());
		}
		return count;
    }
    /**
     * -主函数，
     */
    public static void main(String[] args) {
    	
    }
}
